<?php

include_once '../AtacCommunicator/ACBusWaitingTimes.php';
include_once '../InfoManager/InfoManager.php';
include_once '../Model/BusStop.php';
include_once '../Utility/DebugLogs.php';

ini_set('max_execution_time', '0'); // 0 = no limit.
ini_set("memory_limit",-1);

date_default_timezone_set('Europe/Rome');

$timelimit = date('Y-m-d H:i:s');

$logfile = fopen($_SERVER['DOCUMENT_ROOT'].FILE_LOG,'a');

$infoManager = new InfoManager();

logthis(date("Y-m-d H:i:s").": Inizio di cacheLinesForStops()");
$infoManager->cacheLinesForStops();
logthis(date("Y-m-d H:i:s").": Importate le informazioni relative alle fermate. Ora abbiamo tutto l'elenco delle linee.");
logthis("\n\n");

logthis(date("Y-m-d H:i:s").": Inizio pulizia sulle linee.");

$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
mysql_select_db(DBNAME);
mysql_query("delete from ifermata_linea where lastupdate<'$timelimit'",$conn);
mysql_query("delete from ifermata_fl where lastupdate<'$timelimit'",$conn);
mysql_close($conn);

logthis(date("Y-m-d H:i:s").": Fine.");

//$infoManager->cachePathIDsForLines();
//$infoManager->cacheStopsForPaths();

?>
